<table class="site_sysusers">
</table>
<script>
    $(function(){
        $(".site_sysusers").datagrid({
            url:'../site-users/loadList.action',
            method:'post',
            fitColumns:true,
            idField:'id',
            columns:[[
                {field:'username',title:'用户名',width:100},
                {field:'locked',title:'状态',width:100,
                    formatter: function(value,row,index){
                        if (value == 1){
                            return "锁定";
                        } else {
                            return "正常";
                        }
                    }
                },
            ]],
            toolbar: [{
                iconCls: 'icon-add',
                handler: function(){
                    loadCurrent('添加用户','../site-users/showadd.action');
                }
            },{
                iconCls: 'icon-edit',
                handler: function(){
                    loadCurrent('编辑用户','../site-users/showadd.action');
                }
            },{
                iconCls: 'icon-remove',
                handler: function(){
                    var selections = $('.site_sysusers').datagrid('getSelections');
                    if(selections.length>0){
                        $.messager.confirm('确认','您确认想要删除记录吗？',function(r){
                            if (r){
                                var ids = "";
                                for(var i=0;i<selections.length;i++){
                                    if(i==0){
                                        ids += selections[i].id;
                                    }else{
                                        ids +=","+selections[i].id;
                                    }
                                }
                                $.get('../site-users/delete.action?ids='+ids,null,function (res) {
                                    if(res.result == 'success'){
                                        $(".site_sysusers").datagrid("reload");
                                    }
                                });
                            }
                        });
                    }else{
                        $.messager.alert('警告','请选择要删除的记录！');
                    }
                }
            }],
            pagination:true,
            fit:true,
            border:false,
            doSize:true
        });
    });
</script>